using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using emp.Utility;
using emp.Model;
using emp.BLL;

namespace emp.ProcessFlow
{
    public class QuestionnaireController
    {
        private const string URL_LIST = "QuestionnaireList.aspx";


        public QuestionnaireController()
        { 
            
        }

        public bool Create(QuestionnaireInfo newInfo, string sMenuID)
        {

            try
            {
                // Creata a new business logic tier
                Questionnaire myQunaire = new Questionnaire();

                // Call the insert method
                if (myQunaire.Insert(newInfo) < 1)
                {
                    return false;
                }
            }
            catch (Exception error)
            {
                string sMethod = "emp.ProcessFlow.QuestionnaireController.Create()";
                EventsLog.WriteLog(error, sMethod);
                return false;
            }

            //Finally forward to the welcome page
            HttpContext.Current.Response.Redirect(URL_LIST + "?MenuID=" + sMenuID, true);
            return true;
        }

        public bool Update(QuestionnaireInfo updatedInfo, string sCurPage, string sMenuID)
        {

            // Create the business logic tier
            Questionnaire myQunaire = new Questionnaire();

            // Call the udpate method
            if (myQunaire.UpdateNew(updatedInfo) < 1)
            {
                return false;
            }

            //Redirect the user to the my account page
            HttpContext.Current.Response.Redirect(URL_LIST + "?page=" + sCurPage + "&MenuID=" + sMenuID, true);
            return true;
        }

        public bool Delete(int iQunaireID, string sCurPage, string sMenuID)
        {

            // Create the business logic tier
            Questionnaire myQunaire = new Questionnaire();

            // Call the udpate method
            if (myQunaire.Delete(iQunaireID) < 1)
            {
                return false;
            }

            //Redirect the user to the my account page
            HttpContext.Current.Response.Redirect(URL_LIST + "?page=" + sCurPage + "&MenuID=" + sMenuID, true);
            return true;
        }

        public bool CreateTmpTable(int iQunaireID, string sCurPage)
        {

            // Create the business logic tier
            Questionnaire myQunaire = new Questionnaire();

            // Call the udpate method
            if (myQunaire.CreateTmpTable(iQunaireID) < 1)
            {
                return false;
            }

            //Redirect the user to the my account page
            HttpContext.Current.Response.Redirect(URL_LIST + "?page=" + sCurPage, true);
            return true;
        }


    }
}
